// Tabs
jQuery(document).ready(function($){
	$('.tabs a').click(function(){
		switch_tabs($(this));
	});
	switch_tabs($('.defaulttab'));
	function switch_tabs(obj) {
		$('.tab-content').hide();
		$('.tabs a').removeClass("selected");
		var id = obj.attr("rel");
		$('#'+id).show();
		obj.addClass("selected");
	}
});
// Content Toggle
jQuery(document).ready(function($){
    // Initial state of toggle (hide)
    $(".slide_toggle_content").hide();
    // Process Toggle click (http://api.jquery.com/toggle/)
    $("h4.slide_toggle").toggle(function(){
	    $(this).addClass("clicked");
	}, function () {
	    $(this).removeClass("clicked");
    });
    // Toggle animation (http://api.jquery.com/slideToggle/)
    $("h4.slide_toggle").click(function(){
	$(this).next(".slide_toggle_content").slideToggle();
    });
});
// Content Toggle
jQuery(document).ready(function($){
    // Initial state of toggle (hide)
    $(".slide_toggle_compact_content").hide();
    // Process Toggle click (http://api.jquery.com/toggle/)
    $("h4.slide_toggle_compact").toggle(function(){
	    $(this).addClass("clicked_compact");
	}, function () {
	    $(this).removeClass("clicked_compact");
    });
    // Toggle animation (http://api.jquery.com/slideToggle/)
    $("h4.slide_toggle_compact").click(function(){
	$(this).next(".slide_toggle_compact_content").slideToggle();
    });
});

// nivo
jQuery(document).ready(function($) {
	$('#slider').nivoSlider();
});

// Hover Zoom
jQuery(document).ready(function($){
	$(".gallery-zoom, .gallery-zoom-video").hover(function(){
			$(this).children("span").stop().fadeTo(300, 1); 
		},function(){
			$(this).children("span").stop().fadeTo(300, 0);
	});
});

//Tooltips
jQuery(document).ready(function($){
	var tip;
	$(".tip_trigger").hover(function(){

		//Caching the tooltip and removing it from container; then appending it to the body
		tip = $(this).find('.tip').remove();
		$('body').append(tip);

		//tip.show(); //Show tooltip
		tip.fadeIn('fast'); //Show tooltip and fad it in and out

	}, function() {

		tip.hide().remove(); //Hide and remove tooltip appended to the body
		$(this).append(tip); //Return the tooltip to its original position

	}).mousemove(function(e) {
	//console.log(e.pageX)
		  var mousex = e.pageX + 20; //Get X coodrinates
		  var mousey = e.pageY + 20; //Get Y coordinates
		  var tipWidth = tip.width(); //Find width of tooltip
		  var tipHeight = tip.height(); //Find height of tooltip

		 //Distance of element from the right edge of viewport
		  var tipVisX = $(window).width() - (mousex + tipWidth);
		  var tipVisY = $(window).height() - (mousey + tipHeight);

		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth - 20;
			$(this).find('.tip').css({  top: mousey, left: mousex });
		} if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 20;
			tip.css({  top: mousey, left: mousex });
		} else {
			tip.css({  top: mousey, left: mousex });
		}
	});
});	

// no conflict supersleight
var J = jQuery.noConflict();
J(document).ready(function() {J('body').supersleight();});

jQuery(document).ready(function($){
	$("a[rel^='prettyPhoto']").prettyPhoto();
});